package com.kfm.login.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kfm.login.domain.SysUser;
import com.kfm.login.mapper.SysUserMapper;
import com.kfm.login.service.SysUserService;
import com.kfm.login.util.AesUtil;
import com.kfm.login.util.MailUtil;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.net.URLEncoder;

/**
* @author 10854
* @description 针对表【sys_user】的数据库操作Service实现
* @createDate 2023-11-20 12:03:46
*/
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser>
    implements SysUserService{

    @Override
    @Async // 异步发送邮件
    public void sendEmail(String to, String activeUrl) {
        if (to == null){
            return; // TODO 抛出异常
        }
        try {
            activeUrl += "?email=" + URLEncoder.encode(AesUtil.AES_CBC_Encrypt_String(to));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        MailUtil.sendActiveMail(to,activeUrl);
    }
}




